package com.dc.designPattern._4_builder.impl.improve;

/**
 * Description: 建造者_指挥者
 * @author: gdc
 * @date: 2021/3/9
 * @version 1.0
 */
public class HouseDirector {

    /**
     * 建造者抽象类，聚合关系
     */
    private HouseBuilder houseBuilder;

    /**
     * 方式1，构造器传入 houseBuilder
     */
    public HouseDirector(HouseBuilder houseBuilder) {
        this.houseBuilder = houseBuilder;
    }

    /**
     * 方式2，通过setter 传入 houseBuilder
     */
    public void setHouseBuilder(HouseBuilder houseBuilder) {
        this.houseBuilder = houseBuilder;
    }

    /**
     * 如何处理建造房子的流程，交给指挥者
     * @return              产品
     */
    public House constructHouse(){
        houseBuilder.buildBasic();
        houseBuilder.buildWalls();
        houseBuilder.roofed();
        return houseBuilder.build();
    }
}
